package ui.universescreen;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;

import ui.ImagePanel;
import ui.ScreenPanel;
import ui.ScreenPanelManager;
import ui.VisualSector;
import ui.newgamescreen.NewGameScreenPanel;

import engine.GameStance;
import engine.Sector;
import engine.StarMap;

/**
 * Реализация игрового окна игры
 * 
 * @author Anton Nesterov
 */
public class UniverseScreenPanel extends ScreenPanel {

	private static final long serialVersionUID = 1L;
	public final JPanel grid = new JPanel();

	/* Реализация шаблона - Синглтон */
	private static UniverseScreenPanel instance;

	/**
	 * @return the instance
	 */
	public static synchronized UniverseScreenPanel getInstance() {
		if (instance == null) {
			instance = new UniverseScreenPanel();
		}
		return instance;
	}

	private UniverseScreenPanel() {

		setOnCreateProperties("image/starmap_bgd.jpg");

		JPanel grid = new JPanel(new GridLayout(7, 7, 0, 0));
		grid.setOpaque(false);

		/* Заполнение звездной карты */
		GameStance gameStance = GameStance.getInstance();
		gameStance.getStarmap().getCoordinateNet();
		for (Sector[] lineElement : gameStance.getStarmap().getCoordinateNet()) {
			for (Sector element : lineElement) {
				grid.add(new VisualSector(element));
			}
		}

		add(grid);
		
		/* Добавляем блок слушателей */
		addListeners();
	}

	@Override
	protected void addListeners() {
		// TODO Auto-generated method stub
		
	}

}
